﻿using Microsoft.SharePoint;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MN.Framework.SharePoint.Config
{
    public class MnPortalSettings
    {
        public static T getConfig<T>(string Key)
        {
            var items = SPContext.Current.Web.Lists["MnPortalSettings"].
                           GetItems(new SPQuery()
                           {
                               Query = string.Format(@"
                            <Where>
                                <Eq>
                                    <FieldRef Name='Key'/>
                                    <Value Type='Text'>{0}</Value>
                                </Eq>
                            </Where>", Key)
                           });

            return (T)Convert.ChangeType(items[0]["Value"].ToString(), typeof(T));
        }
    }
}
